﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;

namespace IPR_TrainExamSys_TY.Search
{
    public partial class FrmPaperDetail : Form
    {
        int iCurPaperTotalFenshu = 0;
        string sExamEmployeeID = "";
        string sPaperID = "";
        string sksls = "";
        public FrmPaperDetail(string ExamEmployeeID, string ExamEmployeeName,string PaperID, string PaperName,string ExamSJ,string ExamAddr,string TotalCJ,string ksls)
        {
            InitializeComponent();
            sExamEmployeeID = ExamEmployeeID;
            lbExamEmployee.Text = ExamEmployeeName;
            lbPaperName.Text = PaperName;
            lbExamSJ.Text = ExamSJ;
            lbExamAddr.Text = ExamAddr;
            lbTotalCJ.Text = TotalCJ;
            sPaperID = PaperID;
            sksls = ksls;
        }

        private void FrmPaperDetail_Load(object sender, EventArgs e)
        {
            getPaperDe(sPaperID, sExamEmployeeID);
        }

        private void getPaperDe(string paperbh,string examemployeeid)
        {
            try
            {
                string sql = " select c.gh,c.paperBh, case when a.tix=0 then '判断题' else case when a.tix=1 then '选择题' else case when a.tix=2 then '填空题' else case when a.tix=3 then '简答题' else case when a.tix=4 then '综合题' end end end end end  as tix, " +
                    " a.stbh,ShiT,'' as ShiTi,case when b.RightAnswer='Y' then '对' else case when b.RightAnswer='N' then '错' else b.RightAnswer end end  as bAnswer," +
                " case when a.RightAnswer='Y' then '对' else case when a.RightAnswer='N' then '错' else a.RightAnswer end end as RightAnswer,b.bFenzhi ," +
                "    a.fs  " +
                " from pe_llksjginfo a  " +
                " left join pe_Tik b on a.stbh=b.bh " +
                " left join pe_llksjg c on a.ksls=c.ksls " +
                " WHERE a.ksls='"+sksls+"'";
                DataSet ds = new T_Public().Query(sql);
                if (ds != null)
                    if (ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            iCurPaperTotalFenshu = 0;
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                iCurPaperTotalFenshu += Convert.ToInt32(ds.Tables[0].Rows[i]["bFenzhi"].ToString());
                                byte[] bShiT = (byte[])ds.Tables[0].Rows[i]["ShiT"];
                                string sShiT = Encoding.Default.GetString(bShiT);
                                ds.Tables[0].Rows[i]["ShiTi"] = sShiT;
                            }
                            superGridControl2.PrimaryGrid.Title.Text = "试卷题目信息  总试题数量：" + ds.Tables[0].Rows.Count.ToString() + "   总分数：" + iCurPaperTotalFenshu.ToString();

                            superGridControl2.PrimaryGrid.DataSource = ds.Tables[0];
                        }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "提示");
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
